package com.lintesis.lintesisview.webgui.protocolo.analisis;

import org.zkoss.zkplus.databind.BindingListModel;
import org.zkoss.zkplus.databind.BindingListModelList;
import org.zkoss.zul.Combobox;
import org.zkoss.zul.Textbox;

import com.lintesis.lintesismodel.common.hibernate.GenericDAO;
import com.lintesis.lintesismodel.protocolo.Analisis;
import com.lintesis.lintesismodel.protocolo.Desgloce;
import com.lintesis.lintesismodel.protocolo.Metodo;
import com.lintesis.lintesisview.common.ABMDialogCtrl;
import com.lintesis.lintesisview.common.menu.UserWorkspace;

public class AnalisisDialogCtrl extends ABMDialogCtrl<Analisis>{

	private static final long serialVersionUID = 6171875321822788939L;
	
	static final String rightPreffix = "composicion.dialog.";
	
	Textbox tbNombre;
	Combobox cbMetodo;
	Combobox cbDesgloce;
	
	BindingListModel lmMetodo;
	BindingListModel lmDesgloce;

	@Override
	protected void doSetClearComponents() {
		clearComponents.add(tbNombre);
		clearComponents.add(cbMetodo);
		clearComponents.add(cbDesgloce);
	}

	@Override
	protected void doSetFieldProperties() {
		// TODO Auto-generated method stub
		
	}

	@Override
	protected void doSetReadOnlyComponents() throws Exception {
		roComponents.addAll(clearComponents);
		
	}

	@Override
	protected void doSetValidation() throws Exception {
		// TODO Auto-generated method stub
		
	}

	@Override
	protected void fillBussinesObject() throws Exception {
		// TODO Auto-generated method stub
		
	}

	@Override
	protected void fillComboBoxs() throws Exception {
		try
		{
			lmMetodo = new BindingListModelList(new GenericDAO<Metodo>(UserWorkspace.getInstance().gethSession()).getByBussinessObject(new Metodo()), true);
		} catch (Exception e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		try
		{
			lmDesgloce = new BindingListModelList(new GenericDAO<Desgloce>(UserWorkspace.getInstance().gethSession()).getByBussinessObject(new Desgloce()), true);
		} catch (Exception e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

	@Override
	public String getEntityName() {
		return "Analisis";
	}

	@Override
	protected Analisis getNewEntidad() {
		Analisis analisis=new Analisis();
		return analisis;
	}

	@Override
	protected String getRightPreffix() {
		return rightPreffix;
	}

}
